
package com.joysuch.wwyt.datadump.biz.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.zlg.common.datadump.annotation.DataDumpEntity;
import cn.zlg.common.datadump.annotation.DataDumpField;
import cn.zlg.common.springmvc.validate.constraints.CustomValidator;
import com.joysuch.wwyt.datadump.biz.convertor.*;
import com.joysuch.wwyt.datadump.biz.processor.EduQuestionExportProcessor;
import com.joysuch.wwyt.datadump.biz.processor.EduQuestionImportProcessor;
import com.joysuch.wwyt.datadump.biz.query.EduQuestionDumpQueryBean;
import com.joysuch.wwyt.edu.entity.dsl.QEduQuestion;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@DataDumpEntity(name = "edu-question-dump", entity = QEduQuestion.class, exportQueryConditions = EduQuestionDumpQueryBean.class,
        exportProcessors = EduQuestionExportProcessor.class, importProcessors = EduQuestionImportProcessor.class,
        businessName = "试题")
@Data
public class EduQuestionDumpBean {

    // 导出用，试题ID
    @DataDumpField(field = "id", importIgnore = true)
    private Long id;

    @NotNull
    @Excel(name = "试题编号", width = 16)
    @DataDumpField(field = "code", importKey = true)
    @Length(max = 10)
    private String code;

    @NotNull
    @Excel(name = "试题类型", width = 15)
    @DataDumpField(field = "questionTypeId", importConvertors = ImportQuestionTypeIdConvertor.class, exportConvertors = ExportQuestionTypeIdConvertor.class)
    private String questionTypeName;

    @NotNull
    @Excel(name = "试题名称", width = 40)
    @DataDumpField(field = "name")
    private String name;

    @NotNull
    @Pattern(regexp = "单选题|多选题|判断题|主观题", message = "只能填写以下内容" + "\"单选题|多选题|判断题|主观题\"")
    @Excel(name = "题型")
    @DataDumpField(field = "type", importConvertors = ImportQuestionTypeConvertor.class, exportConvertors = ExportQuestionTypeConvertor.class)
    private String type;

    //    @NotNull
//    @Pattern(regexp = "[A-Z]|([A-Z],)+[A-Z]?", message = "答案必须是大写字母, 多个答案之间使用【英文逗号】分隔")
    @CustomValidator(notNull = "",
            valueCheck = "{\"relatedField\":\"type\",\"relatedFieldNotValue\":\"主观题\",\"regexp\":\"[A-Z]|([A-Z],)+[A-Z]?\",\"message\":\"答案必须是大写字母, 多个答案之间使用【英文逗号】分隔\"}")
    @Excel(name = "答案", width = 16)
    @DataDumpField(field = "answer", exportConvertors = ExportEduQuestionJudgeAnswerConvertor.class)
    private String answer;

    //    @NotNull
    @CustomValidator(notNull = "{\"relatedField\":\"type\",\"relatedFieldNotValue\":\"主观题\"}")
    @Excel(name = "选项A", width = 20)
    private String choiceA;

    //    @NotNull
    @Excel(name = "选项B", width = 20)
    @CustomValidator(notNull = "{\"relatedField\":\"type\",\"relatedFieldNotValue\":\"主观题\"}")
    private String choiceB;

    @Excel(name = "选项C", width = 20)
    private String choiceC;

    @Excel(name = "选项D", width = 20)
    private String choiceD;

    @Excel(name = "选项E", width = 20)
    private String choiceE;

    @Excel(name = "选项F", width = 20)
    private String choiceF;

    @Excel(name = "选项G", width = 20)
    private String choiceG;

    @Excel(name = "选项H", width = 20)
    private String choiceH;


}
